#ifndef LOGINWINDOW_HPP
#define LOGINWINDOW_HPP

#include <QCheckBox>
#include <QLabel>
#include <QLineEdit>
#include <QMainWindow>
#include <QMouseEvent>
#include <QPushButton>
#include <QString>
#include <QVBoxLayout>
class LoginWindow : public QMainWindow {
  Q_OBJECT

public:
  explicit LoginWindow(QWidget *parent = nullptr);
  ~LoginWindow();
  void paintEvent(QPaintEvent *event) override; // 添加绘制事件以支持圆角窗口

protected:
  // 添加鼠标事件处理，用于支持无边框窗口的拖拽
  void mousePressEvent(QMouseEvent *event) override;
  void mouseMoveEvent(QMouseEvent *event) override;
  void mouseReleaseEvent(QMouseEvent *event) override;

private slots:
  void onLoginButtonClicked();
  void onRegisterButtonClicked();

private:
  QWidget *centralWidget;
  QVBoxLayout *mainLayout;

  QLabel *titleLabel;
  QLabel *subtitleLabel;

  QLineEdit *usernameEdit;
  QLineEdit *passwordEdit;
  QCheckBox *rememberMeCheckbox;

  QPushButton *loginButton;
  QPushButton *registerButton;

  QPixmap backgroundImage;

  // 窗口拖拽相关变量
  bool isDragging;
  QPoint dragPosition;

  void setupUI();
  void setupConnections();
  bool validateInput();
};

#endif // LOGINWINDOW_HPP